<#-- ----------  BEGIN 字段循环遍历  ---------->
    <#list introspectedTable.allColumns as allColumns>
        <#if allColumns.remarks!?length gt 0>
            <#assign _consts=allColumns.remarks!/>
        <#--适配zfn枚举注释格式： 业务类型;(0-订单-xxx；1-合约-xxx；)-->
        <#--中文特殊符替换-->
            <#assign _consts=_consts?replace("-1","~1")/><#--负数替换处理，避免被-符合当成分隔符，最后在还原-->
            <#assign _consts=_consts?replace("-2","~2")/>
            <#assign _consts=_consts?replace("-3","~3")/>
            <#assign _consts=_consts?replace("-4","~4")/>
            <#assign _consts=_consts?replace("-5","~5")/>
            <#assign _consts=_consts?replace("-6","~6")/>
            <#assign _consts=_consts?replace("-7","~7")/>
            <#assign _consts=_consts?replace("-8","~8")/>
            <#assign _consts=_consts?replace("-9","~9")/>

            <#assign _consts=_consts?replace("；",";")/>
            <#--<#assign _consts=_consts?replace("（","(")/>
            <#assign _consts=_consts?replace("）",")")/>-->
        <#--    <#assign _consts=_consts?replace("，",",")/>-->
        <#--转成 标准格式  #a,1,xxx-->  <#--中文（）不会转英文，用来后面替换成逗号-->
            <#assign _consts=_consts?replace(";(","#")/>
            <#assign _consts=_consts?replace(";（","#")/>

            <#assign _consts=_consts?replace(";","#")/>
            <#assign _consts=_consts?replace("，","#")/>
            <#assign _consts=_consts?replace("-",",")/>
            <#assign _consts=_consts?replace(";)","")/>
            <#assign _consts=_consts?replace("（",",")/>
            <#assign _consts=_consts?replace("）","")/>
            <#assign _consts=_consts?replace(")","")/>

            <#assign _consts=_consts?replace("~","-")/><#--负数替换处理，避免被-符合当成分隔符，最后在还原-->
            <#assign _consts=_consts?substring(allColumns.remarks!?index_of("#")+1)/>

        <#--标记是否创建当前枚举-->
            <#assign isCreateCurEnum=false />
            <#if _consts!?length gt 0 >
                <#list _consts?split("#") as item>
                    <#assign itemEachs = item?split(",") />
                    <#--字段：${item!} 分割长度:${_subItem?size}-->
                    <#if itemEachs?size == 3 || (itemEachs?size gte 3 && allColumns.remarks!?index_of("$")!=-1)>
                        <#assign isCreateCurEnum=true />
                        <#else >
                            <#--${(itemEachs?size gte 3 && allColumns.remarks!?index_of("$")!=-1)?string}
                        size:${itemEachs?size} :: ${allColumns.remarks!} false........-->
                    </#if>
                </#list>
            </#if>
            <#--忽略字段，多个用英文逗号隔开-->
            <#if introspectedTable.tableConfiguration.properties.ignoreEnumColumns!?index_of(allColumns.actualColumnName) &gt;=0><#assign isCreateCurEnum=false /></#if>
        <#--${isCreateCurEnum?string} ${_consts!}   fffffffffffffffffffffffff-->
            <#if isCreateCurEnum >
    /***
     * ---------------------------
     * @Description: ${allColumns.remarks!}<#--${allColumns.remarks!?substring(0,allColumns.remarks!?index_of("#"))?trim}-->
     * 解析后备注: ${_consts!}
     * db字段：${allColumns.actualColumnName}
     * ---------------------------
     * @author: ${introspectedTable.tableConfiguration.properties.auther!}
     * @date: ${introspectedTable.tableConfiguration.properties.createTime!}
     * @version: v1.0
     * ---------------------------
     */
    @Getter
    @AllArgsConstructor
    public enum ${allColumns.javaProperty?cap_first}Enum {
                    <#assign _isNumber=(allColumns.jdbcTypeName=="INTEGER"||allColumns.jdbcTypeName=="INT"||allColumns.jdbcTypeName=="NUMBER"||allColumns.jdbcTypeName=="TINYINT")?string("1","0")/>

                <#if allColumns.remarks!?index_of("$") gt 0>
                    <#assign paramNameStrs=allColumns.remarks!?substring(allColumns.remarks!?index_of("$")+1)/>
                    <#assign paramNameStrShuZu = paramNameStrs?split("$") />
                    <#assign paramNameStr = paramNameStrShuZu[0]?trim />

                    <#list _consts?split("#") as item>
                        <#assign itemEachs = item?split(",") />
        /** ${itemEachs[2]?trim} **/
                        <#if _isNumber=="1">
       <#list item?split(",") as itemEach><#if itemEach_index == 0> <#elseif itemEach_index == 1>(<#elseif itemEach_index == 2>,"<#else >","</#if>${(itemEach?trim)?upper_case}</#list>"),<#--(byte)后端规范要求TINYINT使用java中的integer,所以不加byte-->
                        <#else>
                            <#list item?split(",") as itemEach><#if itemEach_index == 0> <#elseif itemEach_index == 1>("<#elseif itemEach_index == 2>","<#else >","</#if>${(itemEach?trim)?upper_case}</#list>"),<#--(byte)后端规范要求TINYINT使用java中的integer,所以不加byte-->
                        </#if>
                    </#list>

        ;

        <#list paramNameStr?split(",") as itemField>
            <#if itemField_index == 0>
        private final ${allColumns.fullyQualifiedJavaType.shortNameWithoutTypeArguments} <#else >
        private final String </#if>${itemField?trim};</#list>

        <#list paramNameStr?split(",") as itemField><#if itemField_index == 0>public static final Map<${allColumns.fullyQualifiedJavaType.shortNameWithoutTypeArguments}, ${allColumns.javaProperty?cap_first}Enum> <#else >
        public static final Map<String, ${allColumns.javaProperty?cap_first}Enum> </#if>${itemField?trim}EnumMap = new LinkedHashMap<>();</#list>

        static {
            ${allColumns.javaProperty?cap_first}Enum[] enums = ${allColumns.javaProperty?cap_first}Enum.values();

            for (${allColumns.javaProperty?cap_first}Enum en : enums) {
            <#list paramNameStr?split(",") as itemField>
                //字段不唯一则会被覆盖
                ${itemField?trim}EnumMap.put(en.${itemField?trim}, en);
            </#list>
            }
        }

        <#list paramNameStr?split(",") as itemField>
        public static Optional<${allColumns.javaProperty?cap_first}Enum> getEnumBy${(itemField?trim)?cap_first}(${allColumns.fullyQualifiedJavaType.shortNameWithoutTypeArguments} ${itemField?trim}) {
            return Optional.ofNullable(${itemField?trim}EnumMap.get(${itemField?trim}));
        }
        </#list>

    }<#--带$备注，多个字段的枚举生成结束-->
                <#else>
                    <#list _consts?split("#") as item>
                        <#assign itemEachs = item?split(",") />
                        <#if itemEachs?size gte 3>
                            <#if _isNumber=="1">
        /** ${itemEachs[1]?trim} **/
        ${(itemEachs[2]?trim)?upper_case}(<#if allColumns.jdbcTypeName=="TINYINT"><#--(byte)后端规范要求TINYINT使用java中的integer--></#if>${itemEachs[0]?trim}, "${itemEachs[1]?trim}"),

                            <#else>
        /** ${itemEachs[1]?trim} **/
        ${(itemEachs[2]?trim)?upper_case}("${itemEachs[0]?trim}", "${itemEachs[1]?trim}"),

                            </#if>
                        </#if>
                    </#list>

        ;

            private final ${allColumns.fullyQualifiedJavaType.shortNameWithoutTypeArguments} code;
            private final String name;

            public static final Map<${allColumns.fullyQualifiedJavaType.shortNameWithoutTypeArguments}, ${allColumns.javaProperty?cap_first}Enum> codeEnumMap;
            public static final Map<String ,${allColumns.javaProperty?cap_first}Enum> nameEnumMap;

            static {
	Map<Integer, ${allColumns.javaProperty?cap_first}Enum> codeEnumMapTmp = new LinkedHashMap<>();
	Map<String, ${allColumns.javaProperty?cap_first}Enum> nameEnumMapTmp = new LinkedHashMap<>();
                ${allColumns.javaProperty?cap_first}Enum[] enums = ${allColumns.javaProperty?cap_first}Enum.values();

                for (${allColumns.javaProperty?cap_first}Enum en : enums) {
                    //字段不唯一则会被覆盖
                    codeEnumMapTmp.put(en.code, en);
                    //字段不唯一则会被覆盖
                    nameEnumMapTmp.put(en.name,en);
                }
	codeEnumMap = Collections.unmodifiableMap(codeEnumMapTmp);
	nameEnumMap = Collections.unmodifiableMap(nameEnumMapTmp);
            }

            public static Optional<${allColumns.javaProperty?cap_first}Enum> getEnumByCode(${allColumns.fullyQualifiedJavaType.shortNameWithoutTypeArguments} code) {
                return Optional.ofNullable(codeEnumMap.get(code));
            }

            public static Optional<${allColumns.javaProperty?cap_first}Enum> getEnumByName(String name) {
                return Optional.ofNullable(nameEnumMap.get(name));
            }

            public static Optional<String> getNameByCode(${allColumns.fullyQualifiedJavaType.shortNameWithoutTypeArguments} code) {
                return getEnumByCode(code).map(en -> en.getName());
            }
    }

                </#if>
            </#if>
        </#if>
    </#list>
